/**
 * Project Name:HomeActivity
 * Date:2016-6-2下午4:53:41
 * Copyright (c) 2016, askzhao All Rights Reserved.
 *
 */
package com.kkd.kkdapp.view;

import com.kkd.kkdapp.R;
import com.readystatesoftware.systembartint.SystemBarTintManager;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.view.Window;
import android.view.WindowManager;

/**
 * ClassName: KKdDialog <br/>
 * date: 2016-6-2 下午4:53:41 <br/>
 *
 * @author askzhao
 * @version 
 */
public class KKdDialog extends Dialog{

	
	protected SystemBarTintManager mTintManager;
	private Context mContext;
	/**
	 * @param context
	 * @param theme
	 */
	public KKdDialog(Context context, int theme) {
		super(context, theme);
		init(context);
	}

	/**
	 * @param context
	 * @param cancelable
	 * @param cancelListener
	 */
	protected KKdDialog(Context context, boolean cancelable,
			OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
		init(context);
	}

	/**
	 * @param context
	 */
	public KKdDialog(Context context) {
		super(context);
		init(context);
	}

	
	/**
	 * init:(这里用一句话描述这个方法的作用). <br/>
	 * @author askzhao
	 * @param context
	 */
	private void init(Context context) {
		mContext = context;
		try {
			initTintManager();
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}
	
	
	@TargetApi(19)
	public void setTranslucentStatus(boolean on) {
		Window win = getWindow();
		WindowManager.LayoutParams winParams = win.getAttributes();
		final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
		if (on) {
			winParams.flags |= bits;
		} else {
			winParams.flags &= ~bits;
		}
		win.setAttributes(winParams);
	}
	/**
	 * 初始化为状态栏为纯黑色
	 */
	private void initTintManager() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			setTranslucentStatus(true);
		}

		mTintManager = new SystemBarTintManager((Activity) mContext);
		mTintManager.setStatusBarTintEnabled(true);
		mTintManager.setNavigationBarTintEnabled(true);
		mTintManager.setStatusBarTintResource(R.color.transparent);
		// mTintManager.setTintColor(0x05FF0000);
	}
}
